package com.example.orderserver.callback;


import com.example.orderserver.feign.ProductFeignNacos;
import com.example.productserverapi.entity.Product;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @author benjamin_5
 * @Description 降级回调处理
 * @date 2023/3/9
 */
@Component
@Slf4j
public class ProductFeignCallBack implements ProductFeignNacos {

    @Override
    public String getInfo() {
        // 降级：给出兜底数据
        return "Cloud7DayProperties{'name':'兜底数据','price':0, 'size': 0}";
    }

    @Override
    public String getByName(String name) {
        // 降级：友好提示
        return "服务走远了，请稍后重试";
    }

    @Override
    public String getByBody(Product product) {
        // 降级：记录日志，直接返回为空
        log.error("product-server服务getByBody接口请求失败");
        return null;
    }

    @Override
    public String getByBody2(Map product) {
        return null;
    }

    @Override
    public String getByBody3(Product product) {
        return null;
    }

    @Override
    public String getByBody4(Product product) {
        return null;
    }
}
